﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.Xml.Linq;
using System.ServiceModel.Web;
using System.ServiceModel.Activation;
using System.Web.Mvc;
using COM.Service;
using COM.Web;
using COM.Data;

namespace SampleApp.Web.WcfService
{
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
    public class UserWcfService : IUserWcfService
    {
        private IPermissionService permissionService = Unity.Instance.GetService<IPermissionService>();
        private ILoginService loginService = Unity.Instance.GetService<ILoginService>();

        [WebInvoke]
        public bool LoginAsAppInterfaceUser(string userName, string password)
        {
            this.permissionService.AllowPermissionItem(EnumWebPermissionName.LoginAsWebAppInterfaceUser);
            this.loginService.LoginAsWebInterfaceUser(userName, password);
            return true;
        }

        [WebInvoke]
        public void SignOut()
        {
            this.permissionService.AllowPermissionItem(EnumWebPermissionName.SignOut);
            this.loginService.LogOut();
        }

    }
}
